package com.chixing.day03.day03_Test;

public class CartTest {
    public static void main(String[] args) {
        Cart product = new Cart(101, "毛绒玩具", 9.8f, "河南");
        Cart product1 = new Cart(102, "遥控汽车", 128f, "北京");
        Cart product2 = new Cart(103, "toy1", 35.6f, "上海");
        Cart product3 = new Cart(104, "toy2", 12.5f, "苏州");
        Cart product4 = new Cart(105, "toy3", 99.5f, "哈尔滨");
        Cart product5 = new Cart(106, "toy4", 15.6f, "宿迁");
        Cart product6 = new Cart(107, "toy5", 32.5f, "南京");
        Cart product7 = new Cart(108, "toy6", 400.5f, "南通");
        Cart product8 = new Cart(109, "toy7", 99.5f, "滁州");
        Cart product9 = new Cart(110, "toy8", 19.8f, "马鞍山");
        Cart[] a = {product, product1, product2, product3, product4, product5, product6, product7, product8, product9};
        for (int i = 0; i < a.length; i++) {
            System.out.println(a[i].getProId() + " " + a[i].getProName());
        }
        System.out.println("====================================================================================");
        Cart[] b = {product, product1, product2, product3, product4, product5, product6, product7, product8, product9};
        for (int i = 0; i < b.length; i++) {
            if (b[i].getProPrice() > 300f) {
                System.out.println(b[i].getProId() + " " + b[i].getProName());
            }
        }
        Cart temp = new Cart();
        for (int i = 0; i < b.length; i++) {
            for (int j = i + 1; j < b.length; j++) {
                if (b[i].getProPrice() > b[j].getProPrice()) {
                    temp = b[i];
                    b[i] = b[j];
                    b[j] = temp;
                }
            }
        }
        for (int i = 0; i < b.length; i++) {
            System.out.println(b[i].getProId() + " " + b[i].getProName());
        }

    }
}
